package com.eight.order.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.eight.common.vo.Result;
import com.eight.order.pojo.OrderPayLog;
import com.eight.order.pojo.Order;
import com.eight.order.service.OrderService;
import com.eight.order.vo.OrderVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @program: qy8-education
 * @description:
 * @author: 郑友民（1460115388@qq.com）
 * @create: 2023-05-26 16:09
 **/
@RestController
@RequestMapping("/order/order")
@Api(tags = "订单接口类")
public class OrderController {
    @Autowired
    private OrderService orderService;

    @PostMapping("/getAllOrder/{current}/{pageSize}")
    @ApiOperation("条件分页查询订单")
    public Result getAllOrder(@PathVariable Integer current, @PathVariable Integer pageSize, @RequestBody OrderVo orderVo) {
        Page<Order> orderPage = orderService.getAllOrder(current, pageSize, orderVo);

        return Result.success(orderPage);
    }
    @PostMapping("/queryOrderAndPayLog/{id}")
    @ApiOperation("通过id获取到订单和购买记录")
    public Result queryOrderAndPayLog(@PathVariable String id){
        OrderPayLog orderPayLogs =orderService.queryOrderAndPayLog(id);
        return Result.success(orderPayLogs);
    }
}

